<style>
    * {
        padding: 0px;
        margin: 0px;
    }
    
    html,
    body {
        height: 100%;
        background-color: #000;
        overflow: hidden;
    }
    
    .xueT {
        width: 500px;
        height: 20px;
        background-color: #000;
        border: solid #fff 1px;
        overflow: hidden;
    }
    
    .xueT span {
        height: 20px;
        display: inline-block;
        background-color: red;
        position: absolute;
        z-index: 10;
    }
</style>

<body>
    <div class="xueT"><span style="width: 500px;"></span></div>
</body>
<script>
    setInterval(function() {
        var spanObj = document.querySelector('.xueT span')
        var width = parseInt(spanObj.style.width)
        width -= 5
        spanObj.style.width = width + 'px'
        if (width < 0) {
            clearInterval(star)
            alert("GAME OVER")
        }
    }, 300)

    function random(min, max) {
        return Math.floor(Math.random() * (max - min + 1) + min)
    }
    var star = setInterval(function() {
        var imgObj = document.createElement('img')
        imgObj.src = './star.gif'
        imgObj.width = random(40, 60)
        imgObj.height = random(40, 60)
        imgObj.style.paddingTop = 50
        imgObj.style.position = 'absolute'
        var maxLeft = (window.innerWidth || document.documentElement.clientWidth) - imgObj.width
        imgObj.style.left = random(0, maxLeft) + 'px'
        var maxTop = (window.innerHeight || document.documentElement.clientHeight) - imgObj.height
        imgObj.style.top = random(0, maxTop) + 'px'
        document.body.appendChild(imgObj)
    }, 50)
    document.body.onclick = function(evt) {
        var e = evt || window.event
        var target = e.target || e.srcElement
        if (target.nodeName == 'IMG') {
            document.body.removeChild(target)
            var spanObj = document.querySelector('.xueT span')
            var width = parseInt(spanObj.style.width)
            width += 5
            spanObj.style.width = width + 'px'
        }
    }
</script>